window.onload = function() {
	seajs.use(['jquery-1.8.2.js', 'iscroll_module.js', 'mdialog_module.js', 'util_module.js'], function(Z, I, M, U) {
		var user = U.checkLogin();
		var personVO;
		U.fillHead();
		U.fillTree();
		U.fillFooter();
		initPage();

		function initPage() { //初始化页面
			$("body>div").show();
			$("body .helper_info").show();
			user_info();
			/*if(user.state == 0) {
				//$("body").empty();
				/!*M.toast(false, "请先登录!", function() {
					U.loadLogin(true, false);
				});*!/
			} else {
				$("body>div").show();
				$("body .helper_info").show();
				user_info();
			}*/
		}

		function user_info() {
			U.loadOpt(true);
			U.ajaxget("/person/detailByUid/" + user.info.id, {}, function(json) {
				U.loadOpt(false);
				if(json.success) {
					personVO = json.models.personVO;
					if(personVO.status == "0") {
						location.href = "apply.html";
						return false;
					}
					if(personVO.status == "1"){
						$(".edit_btn").text("审核失败");
						$(".exit_up").click(function() {
							location.href = "personal_apply_edit.html?index=1";
						});
					}
					if(personVO.status == "3"){
						$(".exit_up").hide();
						$(".edit_btn").text("审核中");
					}
					if(personVO.status == "2") {
						$(".exit_up").hide();
						$(".edit_btn").text("审核成功");
						//location.href = "center.html";
						//return false;
					}
					
					$(".name").text(personVO.name);
					$(".mobile").text(personVO.mobile);
					$(".cardCode").text(personVO.cardCode);
					var otherImage = "../images/icons/default_card.png";
					if(U.getImg(personVO.otherImage).length > 0) {
						otherImage = U.getImg(personVO.otherImage)[0];
					}
					//$(".head_img>div:first-child> img").attr("src", headImage);
					$(".fj img").attr("src", otherImage);
					
					$(".companyPhone").text(personVO.companyPhone);
					$(".weixin").text(personVO.weixin);
					$(".email").text(personVO.email);
					$(".sex").text(personVO.sex == 1 ? "女" : "男");
					$(".address").text(personVO.address);
					$(".city").text(personVO.city);
					/*var headImage = "../images/icons/icon_unknow.png";
					if(U.getImg(personVO.headImage).length > 0) {
						headImage = U.getImg(personVO.headImage)[0];
					}*/
					 
					
				} else {
					M.toast(false, json.errorMsg);
				}
				initEvent();
			});
		}

		function initEvent() {
			$(".exit_login").click(function() {
				U.writeCookie("fp_user", "", 1);
				location.href = "index.html";
			});

		}

	});
}